/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ants;

import java.util.ArrayList;

/**
 *
 * @author lnx
 */
public class Cells extends Celda{
    private int dir = -1; //direccion al hormiguero
    private int dist = -1;//distancia al hormiguero
    private int[] pheromone; //lista de feromonas
    private int[] fpheromone; //lista de feromonas
    private int npheromone = 3;
    private int totW; //hormigas trabajadoras enemigas
    private int totE; //hormigas exploradoras enemigas
    private int totG; //hormigas guerreras enemigas
    private int totU; //hormigas desconocidas enemigas
    boolean hasfood = false;
    int know[][] = new int[9][4];
    
    public Cells(){
        super();
        pheromone = new int[npheromone];
        fpheromone = new int[npheromone];
        for(int i = 0; i < npheromone; i++){
            pheromone[i]  = 0;
            fpheromone[i] = 0;
        }
        for(int item[] : know){
            for(int tipos : item){
                tipos = 0;
            }
        }
    }
    public void setDir(int d){
        dir = d;
    }
    public void setDist(int d){
        dist = d;
    }
    public int getDir(){
        return dir;
    }
    public int getDist(){
        return dist;
    }
    public void setPheromone(int t,int q){
        fpheromone[t] = q;
    }
    public void addPheromone(int t,int q){
        fpheromone[t]+=q;
        if(fpheromone[t]>Constantes.maxfer){
            fpheromone[t] = Constantes.maxfer;
        }
    }
    public int getPheromone(int t){
        return pheromone[t];
    }
    public void commit(){
        int k=0;
        for(int i : fpheromone){
            pheromone[k++] = i;
        }
    }
    public void evapore(int t){
        //if (t == 0){return;}
        fpheromone[t]-=Constantes.evap;
        pheromone[t] -=Constantes.evap;
        if(pheromone[t] < 0){
            pheromone[t] = 0;
            fpheromone[t] = 0;
        }
    }
    public void writeknowledge(int knowledge[][]){
        int t[] = new int[4];
        for(int i = 0; i < knowledge.length; i++){
            for(int j = 0; j < knowledge[i].length; j++){
                t[j] += knowledge[i][j];
                switch(j){
                    case 0: setU(t[j]); break;
                    case 1: setW(t[j]); break;
                    case 2: setE(t[j]); break;
                    case 3: setG(t[j]); break;
                }
            }
        }
    }
    
    public void setU(int num){
        totU = num;
    }
    public void setW(int num){
        totW = num;
    }
    public void setE(int num){
        totE = num;
    }
    public void setG(int num){
        totG = num;
    }
    
    public int getW(){
        return totW;
    }
    public int getE(){
        return totE;
    }
    public int getG(){
        return totG;
    }
    public int getU(){
        return totU;
    }
}
